import Vue from 'vue'
import Vuex  from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
    state:{
        info:{
            name:'tom',
            age:20,
            sex:1
        }
    },
    mutations:{
        CHANGENAME(state,val){
            state.info.name = val 
        },
        CHANGEAGE(state,val){
            state.info.age = val
        }
    },
    actions:{
        fnChangeName({commit},value){   
            commit("CHANGENAME",value)
        },
        fnChangeAgeAsync({commit},value){
            setTimeout(()=>{
                commit('CHANGEAGE',value)
            },1000)
        }
    },
})
export default store